-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Правда или действие #8
Правда или действие #8
Conversation
Я еще не все сделала, но хочу отправить, чтобы если что сарзу переделать уже сделанный блок |
Вот теперь все добавила) |
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
index.html
Outdated
|
||
<!-- Изначальное состояние поля для загрузки изображения --> | ||
<fieldset class="img-upload__start"> | ||
<input type="file" id="upload-file" class="img-upload__input visually-hidden" name="filename" required> | ||
<input type="file" id="upload-file" class="img-upload__input visually-hidden" name="filename" action="https://29.javascript.htmlacademy.pro/kekstagram" method="post" enctype="multipart/form-data" accept="image/png, image/jpeg" required> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
За accept + 👍🏻 можно указать "image/*", чтобы вообще все форматы фото принимались. А вот остальные атрибуты здесь лишние
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Исправила
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
js/photo-load.js
Outdated
@@ -0,0 +1,21 @@ | |||
const FILE_TYPES = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
раз ты тут допом проверяешь тип, то с "image/*" могут быть проблемы
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
js/photo-load.js
Outdated
const file = imgInput.files[0]; | ||
const fileName = file.name.toLowerCase(); | ||
const matches = FILE_TYPES.some((it) => fileName.endsWith(it)); | ||
console.log(matches); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лишнее)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
если ты про console.log, то я уже убрала
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
}); | ||
const regexp = /^#[^\s#]+$/i; | ||
|
||
imgInput.addEventListener("change", (evt) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему нельзя все это сделать в одном событии? Сейчас неочевидна логика работы(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Надеюсь правильно поняла, теперь у меня в слушателе для input вызываются слушатели на другие кнопки
} | ||
|
||
}); | ||
function closeForm(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
На закрытие нужно обнулять состояния и скидывать загруженное фото. Сейчас странно работает. Если закрыть через кнопку, то можно загрузить тоже фото, если закрыть через esc, тоже фото нельзя загрузить - оно не сбрасывается из инпута скорее всего.
Плюс слушатели закрытия на закрытие нужно удалять
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Теперь удаляю форму и слушатель на закрытие
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
js/form-filling.js
Outdated
|
||
function validateHastags (value) { | ||
const hashtags = value.trim().split(" "); | ||
if (value.trim() === "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно value.trim() вынести в переменную выше, так как дублируется код.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сделала
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
js/form-filling.js
Outdated
function closeOutside(evt){ | ||
if (!successInner.contains(evt.target)){ | ||
closeSuccess(); | ||
imgOverlay.classList.add("hidden"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в closeSuccess() уже есть этот код
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
убрала
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
js/form-filling.js
Outdated
if(isEscapeKey(evt)) { | ||
evt.preventDefault(); | ||
closeSuccess(); | ||
closeForm(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему по клику форму не закрывать тогда? И вообще нужно ли это делать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, действительно не нужно, убрала вызов этой функции
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
errorButton.addEventListener("click", closeError); | ||
document.addEventListener("keydown", closeErrorEscape); | ||
document.addEventListener("click", closeOutside); | ||
document.removeEventListener("click",closeForm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Может без слушателя лучше, а внутрь других слушателей сложить?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
if(isEscapeKey(evt)) { | ||
evt.preventDefault(); | ||
closeError(); | ||
imgOverlay.classList.remove("hidden"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В других обработчиках нет этого(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В других обработчиках нет этого, так как при нажатии на esc без этой строчки с убиранием класса hidden, у меня закрывалось и модальное окно с фотографией, а в других случаях такого не было
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
Пишу итог по валидациям в одно месте:
Комментарий:
|
А разве если хэш-теги нечувствительны к регистру это не значит, что #ХэшТег #хэштег это одно и то же, просто в этом случае форма не должна проходить валидацию, так как 2 хэш-тега повторяются |
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
8c3a095
into
htmlacademy-univer-javascript-1:master
🎓 Правда или действие
💥 https://htmlacademy-univer-javascript-1.github.io/2579369-kekstagram-5/8/